package com.zyasdk.util;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;

/**
 * Created by Administrator on 2017/11/21.
 * 判断运营商
 */

public class OperatorUtil {

    public static boolean getOperator(String Operatorinfo,Context context){
        TelephonyManager telephonyManager =  (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String IMSI = telephonyManager.getSubscriberId();
        if (IMSI==null||IMSI.equals("null")||IMSI.isEmpty()){
            return false;
        }
        if (Operatorinfo==null||Operatorinfo.equals("null")||Operatorinfo.isEmpty()){
            return true;
        }
        if (IMSI.startsWith("46000")||IMSI.startsWith("46002")){
            if (Operatorinfo.equals("14")){
                return true;
            }
        }else if (IMSI.startsWith("46001") || IMSI.startsWith("46006")){
            if (Operatorinfo.equals("15")){
                return true;
            }
        }else if (IMSI.startsWith("46003") || IMSI.startsWith("46005")) {
            if (Operatorinfo.equals("16")){
                return true;
            }
        }
        return false;
    }
}
